awesome-code-frame
What is this?
This is a fork of @babel/code-frame with the latest dependencies (e.g of chalk) and exported as a pure ESM package. It uses the latest chalk, which means it requires support for package imports. If this causes problems in Jest for you, see this issue for help.
Usage
The package exports a function codeFrameColumns()
which works just like @babel/code-frame
although all dependent types are exported too.
codeFrameColumns( rawLines: string, loc: NodeLocation, opts?: Options ): string;
where NodeLocation
is defined as:
interface NodeLocation {
start: Location;
end?: Location;
}
Location
as:
interface Location {
column: number;
line: number;
};
and Options
as:
export interface Options {
highlightCode?: boolean;
linesAbove?: number;
linesBelow?: number;
forceColor?: boolean;
message?: string;
}